package com.itboye.jinpuyiyuan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.itboye.jinpuyiyuan.R;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/3/14 0014.
 */

public class DateAdapter extends BaseAdapter {
    Context context;
    ArrayList <String> list;
    LayoutInflater inflater;
    ListView dateList;
    boolean isBig=true;//第二个字体放大
    int firstVisibleItem;
    int visibleItemCount;
    public DateAdapter(Context context , ArrayList <String> list,ListView dateList){
        this.context=context;
        this.list=list;
        this.dateList=dateList;
        inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return Integer.MAX_VALUE;
    }

    @Override
    public String getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder holder;
        if (convertView==null){
            holder=new MyViewHolder();
         convertView=inflater.inflate(R.layout.item_date,parent,false);
         holder.date= convertView.findViewById(R.id.contentTv);
         convertView.setTag(holder);
        }else {
          holder= (MyViewHolder) convertView.getTag();
        }

        holder.date.setText(list.get(position%list.size()));
        if (firstVisibleItem+1==position){
            holder.date.setTextColor(context.getResources().getColor(R.color.title_blue));
        }else {
            holder.date.setTextColor(context.getResources().getColor(R.color.black));
        }
//        dateList.setTag(R.integer,holder.date);
//
//        if (position>=3){
//            holder.date.setText(list.get(position));
//            TextView tag = (TextView) dateList.getTag(position - 1);
//            tag.setTextSize(30);
//            tag.setTextColor(context.getResources().getColor(R.color.title_blue));
//        }
        return convertView;
    }

    class MyViewHolder{
        TextView date;
    }

    //传值 让中间的view改变
    public void setViewBigger(int firstVisibleItem){
     this.firstVisibleItem=firstVisibleItem;
     this.notifyDataSetChanged();
    }
}
